
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projekt;

/**
 * Class that displays information do the player via text and graphics.
 */
public class Gui {

    /**
     * Health used in status.
     */
    private String health;
    /**
     * Amount of events to store.
     */
    private final int eventSize = 5;
    /**
     * Damage used in status.
     */
    private String dmg;
    /**
     * Armor used in status.
     */
    private String armor;
    /**
     * Gold used in status.
     */
    private String gold;
    /**
     * EXP used in status.
     */
    private String xp;
    /**
     * Stored variable for dungeon class.
     */
    private Dungeon dg;
    /**
     * Array of strings for events.
     */
    private String[] events = new String[eventSize];
    /**
     * DungeonText object used for getting text strings.
     */
    private DungeonText dText = new DungeonText();

    /**
     * Constructor for GUI. receives Dungeon for access.
     *
     * @param dga = Stored dungeon.
     */
    public Gui(final Dungeon dga) {
        this.dg = dga;
        this.events[0] = " ";
        this.events[1] = " ";
        this.events[2] = " ";
        this.events[3] = " ";
    }

    /**
     * gets the players current health into a string.
     *
     * @return a string with the health.
     */
    public final String getHealth() {
        Hero tempHero = (Hero) dg.getLevel1().getGrid(dg.getLevel1().heroY(),
                dg.getLevel1().heroX());
        health = "Health: " + tempHero.getHp();
        return health;
    }

    /**
     * Get the players current damage into a string.
     *
     * @return a string with the damage.
     */
    public final String getDmg() {
        Hero tempHero = (Hero) dg.getLevel1().getGrid(dg.getLevel1().heroY(),
                dg.getLevel1().heroX());
        dmg = "DMG: " + tempHero.getAttackDmg();
        return dmg;
    }

    /**
     * gets the players current armor.
     *
     * @return a string with the armor.
     */
    public final String getArmor() {
        Hero tempHero = (Hero) dg.getLevel1().getGrid(dg.getLevel1().heroY(),
                dg.getLevel1().heroX());
        armor = "Armor: " + tempHero.getArmor();
        return armor;
    }

    /**
     * Returns a string with the players gold.
     *
     * @return a string containing the gold amount.
     */
    public final String getGold() {
        Hero tempHero = (Hero) dg.getLevel1().getGrid(dg.getLevel1().heroY(),
                dg.getLevel1().heroX());
        gold = "Gold: " + tempHero.getGold();
        return gold;
    }

    /**
     * Gets the players current XP.
     *
     * @return A string containing the players XP.
     */
    public final String getXp() {
        Hero tempHero = (Hero) dg.getLevel1().getGrid(dg.getLevel1().heroY(),
                dg.getLevel1().heroX());
        xp = "XP: " + tempHero.getXp();
        return xp;
    }

    /**
     * Adds an event to the log.
     *
     * @param m monster used.
     * @param h used.
     * @param amount the amount used.
     * @param usage which case.
     */
    public final void addEventCombat(final Creature m,
            final Hero h, final String amount,
            final int usage) {

        events[3] = events[2];
        events[2] = events[1];
        events[1] = events[0];
        switch (usage) {
            //Hero Damage.
            case 1:
                events[0] = h.getName() + dText.getAttacked1()
                        + amount + dText.getAttacked2()
                        + m.getName();
                break;
            //Monster Damage.
            case 2:
                events[0] = m.getName() + dText.getAttacked1()
                        + amount + dText.getAttacked2() + h.getName();
                break;
            //Hero Miss.
            case 3:
                events[0] = h.getName() + dText.getMiss()
                        + m.getName();
                break;
            // Killed monster.
            case 4:
                events[0] = h.getName() + dText.getKilled()
                        + m.getName();
                break;
            // Monster Miss.
            case 5:
                events[0] = m.getName() + dText.getMiss()
                        + h.getName();
                break;
        }



    }

    /**
     * Adds an item pickup to the event list.
     *
     * @param i Item
     * @param h Hero
     * @param amount Number
     * @param usage What item.
     */
    public final void addEventItem(final Items i,
            final Hero h, final String amount1,
            final String amount2, final String amount3,
            final int usage) {
        events[3] = events[2];
        events[2] = events[1];
        events[1] = events[0];
        switch (usage) {
            // Weapon.
            case 1:
                events[0] = h.getName() + dText.getPickedUp()
                        + i.getName() + dText.getPickedUpWeapon1()
                        + amount1 + dText.getPickedUpWeapon2();
                break;
            // Armor.
            case 2:
                events[0] = h.getName() + dText.getPickedUp()
                        + i.getName() + dText.getPickedUpArmor1()
                        + amount1 + dText.getPickedUpArmor2();
                break;
            // Potion.
            case 3:
                events[0] = h.getName() + dText.getPickedUp()
                        + i.getName() + dText.getPickedUpPotion1()
                        + amount1 + dText.getPickedUpPotion2();
                break;
            // Ring.
            case 4:
                events[0] = h.getName() + dText.getPickedUp()
                        + i.getName() + dText.getPickedUpRing1()
                        + amount1 + dText.getPickedUpRing2()
                        + dText.getPickedUpRing2() + amount2
                        + dText.getPickedUpRing4()
                        + dText.getPickedUpRing3() + amount3
                        + dText.getPickedUpRing5();
                break;
            // Gold.
            case 5:
                events[0] = h.getName() + dText.getPickedUp()
                        + i.getName() + dText.getPickedUpGold1()
                        + amount1 + dText.getPickedUpGold2();
                break;
            //Entered Boss.
            case 6:
                events[0] = h.getName() + dText.getEnterBoss();
        }
    }

    /**
     * Get the event in i position.
     *
     * @param i The position.
     * @return The string.
     */
    public final String getEvent(final int i) {
        return events[i];
    }

    /**
     * level up method adds a level up message to the event log.
     */
    public final void levelUp() {
        events[3] = events[2];
        events[2] = events[1];
        events[1] = events[0];
        events[0] = dText.getLevelUp();
    }
}
